﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class LoginForm : System.Web.UI.UserControl
{
    Login lg;
    TBperson tbp;
    protected void Page_Load(object sender, EventArgs e)
    {
       
            this.Label5.Text = "";
            if (Session["person"] != null)
            {
                plogin.Visible = false;
                plcuss.Visible = true;
            }
            else
            {
                plogin.Visible = true;
                plcuss.Visible = false;
            }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        String pcname = "";
        if (Session["person"] == null)
        {
            if (Session["vc"].ToString().Equals(txtcode.Text.Trim().ToUpper()))
            {
                tbp = new TBperson();
                tbp.Pemail= txtname.Text.Trim();
                tbp.Ppwd = MD5.EncodeMD5(txtpwd.Text.Trim());
                if (rbgj.Checked == true)
                {
                    pcname = rbgj.Text;
                }
                if (rbpt.Checked == true)
                {
                    pcname = rbpt.Text;
                }
                lg = new Login();
                if (lg.LoginSys(tbp, pcname.Trim()).Equals("1"))
                {
                    Session["person"] = lg.getMyID(tbp, pcname.Trim());
                    //plcuss.Visible = true;
                    //plogin.Visible = true;
                    Response.Redirect("Resume.aspx");
                }
                else
                {
                    Label5.Text = "<script>alert('登录信息错误!');window.location.href='Default.aspx';</script>";
                }
            }
            else
            {

                Label5.Text = "<script>alert('验证码错误!');window.location.href='Default.aspx';</script>";
            }
        }
        else
        {
            Label5.Text = "<script>alert('您已经登录！');window.location.href='Default.aspx';</script>";
        }
    }
}
